﻿using System;
using System.Configuration;
using System.Windows;
using KinectServer.Module;
using KinectServer.Util;

namespace KinectServer
{
    public class App : Application
    {
        public Kinect KinectObject { get; private set; }
        public FrameServer ServerObject { get; private set; }

        public AsyncFrameBuffer ColorBuffer { get; private set; }
        public AsyncFrameBuffer DepthBuffer { get; private set; }

        private MainWindow _mainWindow;
        private SubWindow _subWindow;

        // Entry point method
        [STAThread]
        public static void Main()
        {
            App app = new App();
            app.Run();
        }

        public App()
        {
            this.ColorBuffer = new AsyncFrameBuffer();
            this.DepthBuffer = new AsyncFrameBuffer();
         
            this.KinectObject = new Kinect();
            this.ServerObject = new FrameServer();

            _mainWindow = new MainWindow();
            _subWindow = new SubWindow();
        }

        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            _mainWindow.Show();
            _subWindow.Show();
            KinectObject.Start();
            ServerObject.Start();
        }

        protected override void OnExit(ExitEventArgs e)
        {
            ServerObject.Stop();
            KinectObject.Stop();
            base.OnExit(e);
        }
    }
}
